/*可写流*/

var fs=require('fs');

var data='God is dog';

var writeStream=fs.createWriteStream('output.txt');

writeStream.write(data, 'UTF8');

/*标记文件结尾*/
writeStream.end();

writeStream.on('finish',function () {
   console.log('写入完成');
})


writeStream.on('error',function (err) {
   console.log(err.stack);
})
